import React, { Component } from 'react'
import { Text, View, Button } from 'react-native'
import { connect } from 'react-redux'

export class List extends Component {
  static navigationOptions = ({ navigation }) => ({
    title: '我是List，我来自' + navigation.state.params.from
  })
  render () {
    console.log('this.props', this.props)
    console.log('navigator', navigator)
    let { state, setParams, navigate, dispatch } = this.props.navigation

    return (
      <View>
        <Text> routeName: {state.routeName} </Text>
        <Text> key: {state.key} </Text>
        <Text> from: {state.params.from} </Text>
        <Button
          title="点我改变参数 from "
          onPress={() => {setParams({from: 'other'})}}>
        </Button>
        <Button
          onPress={() => {navigate('GoBack', {from: 'List', key: state.key})}}
          title="去 goback 页面">
        </Button>
      </View>
    )
  }
}

function select(state) {
  return {
    nav: state.nav
  }
}

export default connect(select)(List)

